<template>
	<view>
		<view v-if="kong==true" class="listbox" v-for="(item,index) in list" :key="index">
			<view class="timebox">{{getTime(item.addtime)}}</view>
			<view class="writebox">
				<view class="titlebox">
					<view>{{item.title}}</view>
					<!-- <image src="../../static/image/gb.png"></image> -->
				</view>
				<view class="infobox">
					<image src="../../static/msg.png"></image>
					<view class="wordbox">{{item.desc}}</view>
				</view>
			</view>
		</view>
		<kong v-if="kong==false"></kong>
		<!-- <kong></kong> -->
	</view>
</template>

<script>
	import kong from '../../components/kong.vue'
	export default {
		components:{
			kong
		},
		data() {
			return {
				list:[],
				kong:null,
			}
		},
		onLoad() {
			this.getlist()
		},
		methods: {
			getlist(){
				uni.showLoading({})
				this.$http({
					url:'/api/wechat/userMessageList',
				}).then(res=>{
					uni.hideLoading()
					this.list = res.data//"is_see": 0, //0未查看 1已查看
					if(this.list.length==0){
						this.kong = false
					}else{
						this.kong = true
					}
					console.log(this.kong,this.list)
				})
			},
			getTime(time) {
				let date = new Date(time * 1000)
				let year = date.getFullYear()
				let month = date.getMonth() + 1
				let day = date.getDate()
				// 时分秒
				let hour = date.getHours()
				let minute = date.getMinutes()
				let second = date.getSeconds()
				return `${year}-${month}-${day} ${hour}:${minute}:${second}`
			},
		}
	}
</script>

<style>
	page{
		background-color: #F7F7F7;
	}
</style>
<style lang="scss" scoped>
	.listbox{
		margin-bottom: 50rpx;
		.timebox{
			font-size: 24rpx;
			font-family: Source Han Sans CN-Regular, Source Han Sans CN;
			font-weight: 400;
			color: #666666;
			margin-bottom: 28rpx;
			text-align: center;
		}
		.writebox{
			width: 656rpx;
			height: 302rpx;
			background: #FFFFFF;
			border-radius: 10rpx;
			padding: 0 17rpx 40rpx 17rpx;
			margin: 0 auto;
			.titlebox{
				height: 112rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				image{
					width: 40rpx;
					height: 40rpx;
				}
			}
			.infobox{
				width: 656rpx;
				height: 152rpx;
				background: #F8F8F8;
				display: flex;
				align-items: center;
				font-size: 28rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #222222;
				image{
					width: 152rpx;
					height: 152rpx;
				}
				.wordbox{
					width: 490rpx;
					margin-left: 14rpx;
				}
			}
		}
	}

</style>
